package com.sinheldrin.musicplayer.music
{
	import com.sinheldrin.musicplayer.fields.Field;
	
	import mx.collections.ArrayCollection;
	import mx.states.OverrideBase;

	public class Music
	{
		private var _id:int;
		public function get id():int
		{
			return _id;
		}
		public function set id(value:int):void
		{
			_id = value;
		}
		
		private var _videoId:String;
		public function get videoId():String
		{
			return _videoId;
		}
		public function set videoId(value:String):void
		{
			_videoId = value;
		}
		
		public function Music()
		{
			_fields = new ArrayCollection();
		}
		
		public function toString():String
		{
			return getFieldByName("Author").value + " - " + getFieldByName("Title").value;
		}
		
		private var _fields:ArrayCollection = null;
		public function get fields():ArrayCollection
		{
			return _fields;
		}

		public function getFieldByName(name:String):Field
		{
			for each (var field:Field in _fields)
			{
				if (field.fieldClass.name == name)
					return field;
			}
			return null;
		}
	}
}